package com.yb.web.global;

import java.io.PrintWriter;
import java.util.List;

import net.sf.json.JSONArray;

import com.yb.base.web.BaseAction;
import com.yb.bussiness.global.SysUserService;
import com.yb.bussiness.global.SysUserServiceImpl;
import com.yb.bussiness.goods.TgPartService;
import com.yb.bussiness.goods.TgPartServiceImpl;
import com.yb.bussiness.shoper.TgBrandMemberService;
import com.yb.bussiness.shoper.TgBrandMemberServiceImpl;
import com.yb.bussiness.shoper.TpBugRecordService;
import com.yb.bussiness.shoper.TpBuyRecordServiceImpl;
import com.yb.domain.goods.TgBrandMember;
import com.yb.domain.goods.TgPart;
import com.yb.domain.goods.TpBuyRecord;
import com.yb.domain.member.TsSysuser;
import com.yb.util.comm.RequestUtil;

@SuppressWarnings("serial")
public class TipAction extends BaseAction {

	private SysUserService userService;
	private TgPartService partService;
	private TpBugRecordService pgService;
	private TgBrandMemberService qgService;

	public TipAction() {
		userService = new SysUserServiceImpl();
		partService = new TgPartServiceImpl();
		pgService = new TpBuyRecordServiceImpl();
		qgService = new TgBrandMemberServiceImpl();
	}

	public String loadYz() {
		PrintWriter out = null;
		try {
			response.reset();
			response.setCharacterEncoding("utf-8");
			out = response.getWriter();
			String time = RequestUtil.getParam(request, "tipTime", "");
			List<TsSysuser> list = userService.loadYzByTime(time);
			out.write(JSONArray.fromObject(list).toString());
		} catch (Exception e) {
			log.error("业主注册监控出错", e);
			out.write("[]");
		}
		return null;
	}

	public String loadSj() {
		PrintWriter out = null;
		try {
			response.reset();
			response.setCharacterEncoding("utf-8");
			out = response.getWriter();
			String time = RequestUtil.getParam(request, "tipTime", "");
			List<TsSysuser> list = userService.loadSjByTime(time);
			out.write(JSONArray.fromObject(list).toString());
		} catch (Exception e) {
			log.error("商家注册监控出错", e);
			out.write("[]");
		}
		return null;
	}

	public String loadSq() {
		PrintWriter out = null;
		try {
			response.reset();
			response.setCharacterEncoding("utf-8");
			out = response.getWriter();
			String time = RequestUtil.getParam(request, "tipTime", "");
			List<TgPart> list = partService.findByTime(time);
			out.write(JSONArray.fromObject(list).toString());
		} catch (Exception e) {
			log.error("申请信息监控出错", e);
			out.write("[]");
		}
		return null;
	}
	
	public String loadPg() {
		PrintWriter out = null;
		try {
			response.reset();
			response.setCharacterEncoding("utf-8");
			out = response.getWriter();
			String time = RequestUtil.getParam(request, "tipTime", "");
			List<TpBuyRecord> list = pgService.loadByTime(time);
			out.write(JSONArray.fromObject(list).toString());
		} catch (Exception e) {
			log.error("拼购申请监控出错", e);
			out.write("[]");
		}
		return null;
	}
	
	public String loadQg() {
		PrintWriter out = null;
		try {
			response.reset();
			response.setCharacterEncoding("utf-8");
			out = response.getWriter();
			String time = RequestUtil.getParam(request, "tipTime", "");
			List<TgBrandMember> list = qgService.loadByTime(time);
			out.write(JSONArray.fromObject(list).toString());
		} catch (Exception e) {
			log.error("抢购申请监控出错", e);
			out.write("[]");
		}
		return null;
	}
}
